package com.rdd.transformation

import org.apache.spark.{SparkConf, SparkContext}

object testMap {

  def main(args: Array[String]): Unit = {

    val conf = new SparkConf().setAppName("testMap").setMaster("local")
    val sc = new SparkContext(conf)

    val txt = sc.textFile("src\\main\\scala\\testTxt.txt")

    /**
     * map
     */
    txt.map(x => (x, 10)).foreach(println)

    txt.map(x => (x.split(" "))).foreach(println)

    /**
     * flatMap
     */
    txt.flatMap(x => (x.split("e"))).foreach(println)

    sc.stop()
  }

}
